{% extends 'base.html.twig' %}
{% block body_bar %}
    <h5>{{ dry_translation('updatePassword') }}</h5>
{% endblock %}
{% block body %}
    <form method="post" action="" onsubmit="return checkUserUpdatePasswordForm()">
        <div class="form-group">
            <label class="control-label">{{ dry_translation('oldPassword') }}</label>
            <input type="password" id="oldPassword" name="oldPassword" required="required" class="form-control">
        </div>
        <div class="form-group">
            <label class="control-label">{{ dry_translation('newPassword') }}</label>
            <input type="password" id="newPassword" name="newPassword" required="required" class="form-control">
        </div>
        <div class="form-group">
            <label class="control-label">{{ dry_translation('newRePassword') }}</label>
            <input type="password" id="newRePassword" name="newRePassword" required="required" class="form-control">
        </div>
        <div class="form-group">
            <input type="submit" class="btn btn-primary btn" value="{{ dry_translation('submit') }}"></input>
        </div>
    </form>
    <script type="text/javascript" src="/public/inspinia/js/jquery-2.1.1.js"></script>
    <script type="text/javascript" src="/public/layer/layer.js"></script>
    <script>
    function checkUserUpdatePasswordForm(){
        var oldPassword = $("#oldPassword").val();
        var newPassword = $("#newPassword").val();
        var newRePassword = $("#newRePassword").val();
        if(oldPassword.length < 9){
            layer.msg("{{ dry_translation('oldPasswordIncorrect') }}");
            return false;
        }
        if(newPassword.length < 9){
            layer.msg("{{ dry_translation('newPassword9characters') }}");
            return false;
        }
        if(newPassword != newRePassword){
            layer.msg("{{ dry_translation('passwordTwoTimeInconsistent') }}");
            return false;
        }
        return true;
    }
    </script>
{% endblock %}
